/**
 * 共阳数码管
 * 数码管0-9 显示 
**/

int ledCount = 8;
const unsigned char code[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f,0x80};//共阴段码0-9,.
int ledPins[]={4,5,6,7,8,9,10,11};  //板子的引脚 a b c d e f g dp

void setup() {
  for(int i = 0; i < ledCount; i++)
  {
    pinMode(ledPins[i],OUTPUT); //输出模式
  }
}

void deal(unsigned char value)
{
  for(int i = 0; i < ledCount ; i++)
  {
    digitalWrite(ledPins[i],!bitRead(value,i)); //按位取反 如 0x3f  0 0 1 1 1 1 1 1     0x06 =  0000 0110   0x6f = 0110 1111
                                                //数码管段码表     dp g f e d c b a
   }
}

void loop() {
  // put your main code here, to run repeatedly:
  for(int i = 0; i < 11; i++)
  {
    deal(code[i]);
    delay(1000);
  }
}
